<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>ArcGIS Server Link for Google Maps Flash API</title>
    <link rel="stylesheet" type="text/css" href="http://code.google.com/css/codesite.css"/>
    <link rel="stylesheet" type="text/css" href="http://gmaps-utility-library.googlecode.com/svn/trunk/util/docs/template/local_extensions.css"/> 
    <script type="text/javascript" src="http://code.google.com/js/prettify.js"></script>
  </head>
  <body onload="prettyPrint()">
<div>
<a name="Top"></a>  
<h1><a></a>ArcGIS Server Link for Google Maps Flash API</h1>
<p>
    <a target="_blank" href="../../../docs/com/google/maps/extras/arcgislink/package-detail.html">Class References</a>&nbsp;
  </p>
</div>
<div>
<h2><a name="TOC"></a>Overview</h2>
    <p>This library is an AS3 port of the
    <a target="_blank" href="http://gmaps-utility-library-dev.googlecode.com/svn/trunk/arcgislink/docs/examples.html">
        JavaScript verion</a> of ArcGIS Link library. It provides access to ESRI&#39;s 
        ArcGIS Server via it&#39;s  
     <a target="_blank" href='http://resources.esri.com/help/9.3/arcgisserver/apis/rest/'> 
        REST API</a> from 
     <a target="_blank" href='http://code.google.com/apis/maps/documentation/flash/intro.html'>
        Google Maps Flash API</a>. The main concepts of this library are:
     </p>
    <ul>
        <li>It uses a two tier object model. It has a REST layer designed around &quot;Service + 
            Operation&quot;. On top of the service layer, there are a number of UI related 
            classes that extends core Google API classes.&nbsp; It is slightly different than the 
            &quot;Task&quot; based model, with the benefit of loading service meta data only once for 
            multiple operations supported by a single type of service. </li>
        <li>For most REST request parameters, there is an equivalent class that takes an 
            optional object literal in constructor. This is to conform with Google API 
            convention for keep the convenience of using object literal while still have 
            some type checking at compile time. </li>
        <li>For most REST operations, the service object will fire a &quot;ServiceEvent&quot; upon 
            completion, instead of different type of events. The result is wrapped as &quot;data&quot; 
            property in the event and can be of different types depending on operation. Like 
            the JavaScript version, most operations take callback functions in parameters. 
            You can use either event model or callback, however callback may have advantage 
            in anonymous function and using closure.</li>
        <li>Because of the async nature of meta loading for ArcGIS services, it is 
            recommended to always use services after ServiceEvent.LOAD is dispatched.</li>
    </ul>
    <p>&nbsp;</p>
    <H2>Examples</H2>
<table style='border:0px'>
  <tr>
    <td style='border:0px'>
        Map Types/Overlays:<br/>
      <ul>
<li><a href="#Dyna">Dynamic Map Service</a></li>
<li><a href="#Mercator">Add Cached Service in Web Mercator tiles</a></li>
<li><a href="#TileLoad">Add Cached Service in Non-Mercator tiles</a></li>
<li><a href="#TileLayerOverlay">Add as TileLayerOverlay</a></li>
<li><a href="#Combined">Combining Tiled and Dynamic Maps</a></li>
<li><a href="#ArcGISOnline">Add ArcGISOnline Maps</a></li>
<li><a href="#Simple">One-step Add Map</a></li>
<li><a href="#StatePlane">State Plane Coordinate System</a></li>
</ul>

    </td>
    <td style="border:0px">
        Services:<br/>
   <ul>
   <li><a href="#MapClick">Identify/MapClick</a></li>
   <li><a href="#LayerDef">Layer Definition</a></li>
   <li><a href="#LayerVis">Layer Visibility (TOC)</a></li>
   <li><a href="#LayerQuery">Layer Query / Mouseover</a></li>
   <li><a href="#Find">Find</a></li>
   <li><a href="#Geocode">Geocode</a></li>
   <li><a href="#ReverseGeocode">ReverseGeocode</a></li>
   <li><a href="#Multiple">Use Multiple Services</a></li>
   </ul>
   </td>
   <td style="border:0px">
        <br/>
   <ul>
   <li><a href="#3D">3D /Perspective</a></li>
   </ul>
   </td>
  </tr>
</table>
</div>
<div>
<h2><a name="HowTo"></a>Include Library</h2>
<p>
    Make sure google maps Flash API&#39;s flex lib and this lib &quot;<a 
        href="../../../bin/ArcGISLinkLib.swc">ArcGISLinkLib.swc</a>&quot; is 
    included in the built path, or check out svn for lastest version. </p>
</div>


<div>
<h2><a name="Dyna"></a>Dynamic Map Service</h2>
<p> ArcGIS Server provides map services to generate map images on the fly, also 
    known as &quot;dynamic map&quot;. Dynamic services are implemented as 
<a href='../../../docs/com/google/maps/extras/arcgislink/ArcGISMapOverlay.html'>ArcGISMapOverlay</a>, a subclass of <code>
        OverlayBase</code>, and hence can be added with <code>map.addOverlay()</code>. 
    This class is similar to the <code>GoundOverlay</code> in the core API, as it 
    essentially draws a single image over the map.

<pre class="prettyprint">
        ov=new ArcGISMapOverlay(url, new ArcGISMapOverlayOptions({alpha: alphaSlider.value}));
        ov.addEventListener(ServiceEvent.LOAD, function (evt:ServiceEvent):void{
          map.addOverlay(ov);
          var bnds:LatLngBounds=ov.initialBounds;
          map.setCenter(bnds.getCenter(),map.getBoundsZoomLevel(bnds));  
        });
</pre>

<p>
<a target="_blank" href="DynamicLayer.html">View Example </a> 
    |
<a target="_blank" href="srcview/source/DynamicLayer.mxml.html">
    Source Code </a> |
<a href="#Top">Back to top</a>
</p>
</div>
<div>
<h2><a name="Mercator"></a>Cached Service in Web Mercator</h2>
<p> 
        If the map service is tiled using the same tiling scheme as Google Maps 
        (WebMercator in ArcGIS), it can be added as a map type directly. The following 
        Example constructs a new
    <code>
        Map</code>
        with only an ArcGIS map type and no Google map types.
</p>
<pre class="prettyprint">
    private function onMapPreInitialize(event:Event):void {
        var url:String=&#39;http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Portland/ESRI_LandBase_WebMercator/MapServer&#39;;
        var agsType:ArcGISMapType=new ArcGISMapType(url);
        var opts:MapOptions=new MapOptions({mapTypes: [agsType], center: new LatLng(45.5, -122.7), zoom: 15});
        map.setInitOptions(opts);
      }

         
</pre>

<p>
<a target="_blank" href="TileLayerMercator.html">View 
    Example </a> |
<a target="_blank" href="srcview/source/TileLayerMercator.mxml.html">
    Source Code </a> |
<a href="#Top">Back to top</a>
</p>
</div>
<div>
<h2><a name="TileLoad"></a>Cached Service in Non-Mercator Tile Scheme</h2>
<p> If the map service is not cached using the same tiling scheme as Google maps, 
    then it can not be loaded directly because the system does not know how to 
    request the tiles. It must instead be added asynchronously, after it&#39;s received 
    information about the scheme. The following Example adds a map service created 
    in ArcGIS online scheme after the <code>&quot;load&quot;</code> event:
<pre class="prettyprint">
      private function onMapReady(event:Event):void {
        map.enableScrollWheelZoom();
        map.addControl(new MapTypeControl());
        map.addControl(new NavigationControl());
        map.setCenter(new LatLng(45.5, -122.7), 15);
        var url:String=&#39;http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Portland/Portland_ESRI_LandBase_AGO/MapServer&#39;;
        var agsTile:ArcGISTileLayer = new ArcGISTileLayer(url);
        agsTile.addEventListener(ServiceEvent.LOAD, function(evt:Event):void {
           var agsType:ArcGISMapType=new ArcGISMapType([agsTile]);
           map.addMapType(agsType);
           map.setMapType(agsType);
        });
      }
</pre>

<p>
<a target="_blank" href="TileLayerAGO.html">View Example </a> 
    |
<a target="_blank" href="srcview/source/TileLayerAGO.mxml.html">
    Source Code </a> |
<a href="#Top">Back to top</a>
</p>
</div>

<div>
<h2><a name="TileLayerOverlay"></a>Add as TileLayerOverlay</h2>
<p> Tile layers can also be added as 
<a href="../../../docs/com/google/maps/extras/arcgislink/ArcGISTileLayerOverlay.html">ArcGISTileLayerOverlay</a>, a 
    subclass of <code>TileLayerOverlay</code> in the core API. If the tile is 
    created with &quot;WebMercator&quot;, it can be added on top of the default Google map 
    types. If it is not in &quot;WebMercator&quot;, it can only be added as an <code>
    ArcGISTileLayerOverlay</code> on top of map types with the same tiling scheme. 
    In this case, it&#39;s best to initialize the map with only the ArcGIS map types.
<pre class="prettyprint">
      private function onMapReady(event:Event):void {
        map.setCenter(new LatLng(45.5, -122.7), 15);
        map.enableScrollWheelZoom();
        map.addControl(new MapTypeControl());
        map.addControl(new NavigationControl());
        var url:String=&#39;http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Portland/ESRI_LandBase_WebMercator/MapServer&#39;;
        tileLayer=new ArcGISTileLayer(url, new ArcGISTileLayerOptions({alpha: alphaSlider.value}));
        tileLayer.addEventListener(ServiceEvent.LOAD, function(event:Event):void {
          addOverlay();
        });
      }

      private function addOverlay():void {
        removeOverlay();
        ov=new ArcGISTileLayerOverlay(tileLayer);
        map.addOverlay(ov);
      }
		</pre>

<p>

<a target="_blank" href="TileLayerOverlay.html">View 
    Example </a> |
<a target="_blank" href="srcview/source/TileLayerOverlay.mxml.html">
    Source Code </a> | <a target="_blank" href="TileLayerOverlay3D.html">View 
    in 3D </a> |
<a href="#Top">Back to top</a>
</p>

</div>



<div>
<h2><a name="Combined"></a>Combining Tiled and Dynamic Layer</h2>
<p>In many situations, it&#39;s ideal to combined a tiled map as a background, with a 
    dynamic layer on top of it. The following Example loads the default Google map 
    types (Normal, Satellite, Hybrid), then a tiled map service built on WGS84(4326) 
    with 521x512 pixel tile size, then a tiled map service built on 
    Web-Mercator(102113) with 256x256 pixel tile size, and finally, a dynamic map 
    service whose own spatial reference system is NAD83 GCS(4269) on top of all. As 
    map type changes, the dynamic map will refresh itself to match the underlying 
    spatial reference.</p>
<pre class="prettyprint">
     private function onMapReady(event:Event):void {
        map.setCenter(new LatLng(45.5, -122.7), 15);
        map.enableScrollWheelZoom();
        map.addControl(new MapTypeControl());
        map.addControl(new NavigationControl());

        var baseUrl:String=&#39;http://sampleserver1.arcgisonline.com/ArcGIS/rest/services&#39;;
        var wgs84Url:String=baseUrl + &#39;/Portland/Portland_ESRI_LandBase_AGO/MapServer&#39;;
        var webMercatorUrl:String=baseUrl + &#39;/Portland/ESRI_LandBase_WebMercator/MapServer&#39;;
        var dynaUrl:String=baseUrl + &#39;/Demographics/ESRI_Census_USA/MapServer&#39;;
        var agoUrl:String=&#39;http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer&#39;;

        var wgs84:ArcGISTileLayer=new ArcGISTileLayer(wgs84Url);
        wgs84.addEventListener(ServiceEvent.LOAD, function(evt:Event):void {
            map.addMapType(new ArcGISMapType([wgs84]));
          });
        var webMercator:ArcGISTileLayer=new ArcGISTileLayer(webMercatorUrl);
        webMercator.addEventListener(ServiceEvent.LOAD, function(s:Event):void {
            map.addMapType(new ArcGISMapType([webMercator], new ArcGISMapTypeOptions({name: webMercator.getName().replace(/ /g, &#39;\n&#39;)})));
          });
        var ago:ArcGISTileLayer=new ArcGISTileLayer(agoUrl);
        ago.addEventListener(ServiceEvent.LOAD, function(e:Event):void {
            map.addMapType(new ArcGISMapType([ago], new ArcGISMapTypeOptions({name: &#39;AGO&#39;})));
          });
        dynaOverlay=new ArcGISMapOverlay(dynaUrl);
        map.addOverlay(dynaOverlay);
      } 
</pre>

<p>
<a target="_blank" href="TileAndDynamic.html">View 
    Example </a> |
<a target="_blank" href="srcview/source/TileAndDynamic.mxml.html">
    Source Code </a> |
<a href="#Top">Back to top</a>
</p>
</div>

<div>
<h2><a name="ArcGISOnline"></a>ArcGISOnline Services</h2>
<p> <a href="http://www.arcgisonline.com">ArcGISOnline</a> is an online geo-spatial 
    service provided by 
<a href="http://www.esri.com">ESRI, Inc</a>. </p>
<p>Check <a href='http://resources.esri.com/arcgisonlineservices/index.cfm?fa=Licensing'>
    Licensing</a> 
    before you use these services. </p>
<p>The following Example creates and loads one ArcGIS base map type, sets that as 
    the maptype for the map, then adds additional services as map type</p>
<pre class="prettyprint">
    private var base:String=&#39;http://server.arcgisonline.com/ArcGIS/rest/services&#39;;
      private function onMapPreInitialize(event:Event):void {
        var url:String=base + &#39;/ESRI_StreetMap_World_2D/MapServer&#39;;
        var agsType:ArcGISMapType=new ArcGISMapType(url, new ArcGISMapTypeOptions({projection:ArcGISTileConfig.ARCGIS_ONLINE}));
        var opts:MapOptions = new MapOptions({
          mapTypes:[agsType],
          center: new LatLng(40, -95), 
          zoom: 4
        });
        map.setInitOptions(opts);
      }
</pre>

<p>
<a target="_blank" href="ArcGISOnline.html">View Example </a> 
    |
<a target="_blank" href="srcview/source/ArcGISOnline.mxml.html">
    Source Code </a> | 
<a href="#Top">Back to top</a>
</p>
</div>

<div><h2><a name="Simple"></a>Simple Add Map</h2> 
<p>In the simplest form, you can add an ArcGIS map with the utility method 
<a href="../../../docs/com/google/maps/extras/arcgislink/ArcGISUtil.html#addArcGISMap()" class="code">
    ArcGISUtil.addArcGISMap(map, url)</a> 
    The service will be added either as a MapType(cached) or Overlay(dynamic). You 
    can optionally use a callback function to do extra things with the result.
 </p>

<pre class="prettyprint">
        var base:String=&#39;http://sampleserver1.arcgisonline.com/ArcGIS/rest/services&#39;;
        var tiled:String=base + &#39;/Portland/Portland_ESRI_LandBase_AGO/MapServer&#39;;
        var dyna:String=base + &#39;/Demographics/ESRI_Census_USA/MapServer&#39;;
        ArcGISUtil.addArcGISMap(map, tiled, function(res:ArcGISMapType):void{
          map.setMapType(res);
        });
        ArcGISUtil.addArcGISMap(map, dyna);
</pre>

<p>
<a target="_blank" href="SimpleAdd.html">View Example </a> 
    |
<a target="_blank" href="srcview/source/SimpleAdd.mxml.html">
    Source Code </a> |
<a href="#Top">Back to top</a>
</p>
</div>

      <div>
          <h2><a name="StatePlane"></a>State Plane Coordinate System</h2>
          <p> Virtually all GIS data collected by State or Local Governments in Unite States 
              are stored in one of the 
<a target="_blank" href="http://en.wikipedia.org/wiki/State_Plane_Coordinate_System">
              State Plane Coordinate Systems</a>. In real-world operations, map services (both 
              tiled and dynamic) are published using the native coordinate system the data 
              uses. </p>
<p>When adding an <a href="../../../docs/com/google/maps/extras/arcgislink/ArcGISTileLayer.html">ArcGISTileLayer</a> 
    from a tiled map service, the spatial reference of the map service must be 
    loaded into the internal 
<a href="../../../docs/com/google/maps/extras/arcgislink/ArcGISSpatialReferences.html">SpatialReferences</a> collections 
    before it can be used. The library has 3 built-in spatial references: NAD GCS 
    (4269), WGS84 (4326) and &quot;Web Mercator&quot; (102113). It also supports any spatial 
    references based on 
<a target=wiki href='http://en.wikipedia.org/wiki/Lambert_conformal_conic_projection'>
    Lambert Conformal Conic Projection</a>
    or <a target=wiki href='http://en.wikipedia.org/wiki/Transverse_Mercator_projection'>
    Transverse Mercator Projection</a>. They can be added either with one line of 
    code by its Well_known_text format or constructed directly with correct 
    parameters. Please use the WKT value from 
<a target=esri href='http://edndoc.esri.com/arcims/9.2/elements/pcs.htm'>
    ESRI documentation</a>. Spatial references based on other projections can be 
    used by extending the 
<a href="../../../docs/com/google/maps/extras/arcgislink/SpatialReference.html">SpatialReference</a> class.</p>
          <p>If you do not want to load Google Tiles, the map instance should be created after 
              the service is loaded because the mapevent_preinitialize may fire before service 
              load.</p>
<pre class="prettyprint">
      private var map:Map;
      private var svc:MapService;
      SpatialReferences.addSpatialReference(2264, &#39;PROJCS[&quot;NAD_1983_StatePlane_North_Carolina_FIPS_3200_Feet&quot;,GEOGCS[&quot;GCS....]]&#39;);

      public function onHolderCreated(event:Event):void {
        svc=new MapService(&#39;http://maps.ci.charlotte.nc.us/ArcGIS/rest/services/GET/BaseMap/MapServer&#39;);
        svc.addEventListener(ServiceEvent.LOAD, onServiceLoad);
      }

      public function onHolderResized(event:Event):void {
        if (map != null) {
          map.setSize(new Point(mapHolder.width, mapHolder.height));
        }
      }

      public function onServiceLoad(event:ServiceEvent):void {
        map=new Map();
        map.key=&quot;ABQIAAAA7QUChpcnvnmXxsjC7s1fCxQGj0PqsCtxKvarsoS-iqLdqZSKfxTd7Xf-2rEc_PC9o8IsJde80Wnj4g&quot;;
        map.width=mapHolder.width;
        map.height=mapHolder.height;
        mapHolder.addChild(map);
        map.addEventListener(MapEvent.MAP_PREINITIALIZE, onMapPreinitialize);
        map.addEventListener(MapEvent.MAP_READY, onMapReady);
      }

      private function onMapPreinitialize(event:Event):void {
        var agsLayer:ArcGISTileLayer=new ArcGISTileLayer(svc);
        var agsMapType:ArcGISMapType=new ArcGISMapType([agsLayer], new ArcGISMapTypeOptions({name: agsLayer.getName().replace(/ /g, &#39;\n&#39;)}));
        var bnds:LatLngBounds=agsLayer.getInitialBounds();
        var opts:MapOptions=new MapOptions();
        opts.zoom=11;
        opts.center=new LatLng(35.227, -80.84); 
        opts.mapTypes=[agsMapType];
        map.setInitOptions(opts);
      }
</pre>

<p>
<a target="_blank" href="StatePlane.html">View Example </a> 
    |
<a target="_blank" href="srcview/source/StatePlane.mxml.html">
    Source Code </a> |
<a href="#Top">Back to top</a></p>
</div>


<div>
<h2><a name="MapClick"></a>Identify/Map Click</h2>
<p> ArcGIS Map Services contains a backend geospatial database that can answer 
    spatial queries about geographic features located at a certain location. Listen 
    to MapEvent.CLICK, run MapService.identify operation, then process results.
</p>
 <pre class="prettyprint">
...
        map.addEventListener(MapMouseEvent.CLICK, doIdentify);
  
      private function doIdentify(evt:MapMouseEvent):void {
        var latlng:LatLng=evt.latLng;
        var bnds:LatLngBounds=map.getLatLngBounds();
        var size:Point=map.getSize();
        var idParams:IdentifyParameters=new IdentifyParameters({
          geometry: latlng, 
          layerOption: &#39;top&#39;, 
          tolerance: 5, 
          bounds: bnds, 
          width: size.x, 
          height : size.y,
          dpi:96,
          returnGeometry: true});
        _svc.identify(idParams, function processResults(res:IdentifyResults):void {
          });
       }</pre>
   

<p>
<a target="_blank" href="MapClick.html">View Example </a> 
    | 
<a target="_blank" href="srcview/source/MapClick.mxml.html">
    Source Code </a> | <a target="_blank" href="MapClick3D.html">View in 3D </a> 
    |
<a href="#Top">Back to top</a></p>
</div>

<div>
<h2><a name="LayerDef"></a>Layer Definition</h2>
<p>You can draw a subset of a feature layer inside a dynamic map service by setting 
    a SQL expression as its <code>definition</code> property. You will have to use 
    the <code>Layer</code> 
    class in the REST part of the libarary.</p>
<pre class="prettyprint">
var service = dynaLayer.getMapService();
service.getLayer(&quot;Coarse Counties&quot;).definition=&quot;STATE_NAME=&#39;Kansas&#39; and POP2007 &gt; 25000&quot;;
service.getLayer(&quot;Detailed Counties&quot;).definition=&quot;STATE_NAME=&#39;Kansas&#39; and POP2007 &gt; 25000&quot;;
service.getLayer(&quot;states&quot;).definition=&quot;STATE_NAME=&#39;Kansas&#39;&quot;;
</pre>

<p>
<a target="_blank" href="LayerDefinition.html">View 
    Example </a> |
<a target="_blank" href="srcview/source/LayerDefinition.mxml.html">
    Source Code </a> | 
<a href="#Top">Back to top</a>
</p>
</div>
<div>
<h2><a name="LayerVis"></a>Layer Visibility (TOC)</h2>
<p> You can control visibility of a layer inside a dynamic map service by setting 
    its <code>visible</code> property. There are some limitations on the scale 
    threshold on layers in the REST API. You will have to load the layer resource 
    individually if you want to do a TOC that handles scales. 
 <pre class="prettyprint">
var service = dynaLayer.getMapService();
service.getLayer(&quot;states&quot;).visible = true;
dynaLayer.refresh();
</pre>

<p>
<a target="_blank" href="LayerVisibility.html">View 
    Example </a> |
<a target="_blank" href="srcview/source/LayerVisibility.mxml.html">
    Source Code </a> | 
<a href="#Top">Back to top</a>
</p>
</div>

<div>
</div>
<div>
<h2><a name="LayerQuery"></a>Layer Query</h2>
<p>You can query a layer with a SQL statement and spatial filters. The result can be 
    displayed as overlays, like markers or polys. You can also attach mouse events 
    to those overlays to make the application more interactive.
</p> 
<pre class="prettyprint">
    private function onMapReady(event:Event):void {
        map.setCenter(new LatLng(35.7, -79.5), 7);
        map.addControl(new com.google.maps.controls.MapTypeControl());
        map.addControl(new NavigationControl());
        map.enableScrollWheelZoom();
        map.enableContinuousZoom();
        layer=new Layer(&#39;http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3&#39;);
        layer.addEventListener(ServiceEvent.LOAD, initFunctionality);
      }

      private function initFunctionality(evt:Event):void {
        var params:QueryParameters=new QueryParameters(
         {returnGeometry: true, 
         where: &quot;STATE_NAME = &#39;North Carolina&#39;&quot;, 
         outFields: [&quot;NAME&quot;, &quot;POP2000&quot;, &quot;POP2007&quot;, &quot;POP00_SQMI&quot;, &quot;POP07_SQMI&quot;]
         });
        layer.query(params, processResultSet, handleError, style);
      }

      private function processResultSet(rs:ResultSet):void {
        var fs:Array=rs.features;
        for (var i:int=0, c:int=fs.length; i &lt; c; i++) {
          var ovs:Array=createGPolys(fs[i], rs.spatialReference);
          for (var j:int=0; j &lt; ovs.length; j++) {
            map.addOverlay(ovs[j]);
          }
        }
      }

      private function createGPolys(feat:Feature, sr:SpatialReference):Array {
        var a:*=feat.attributes;
        ...
        }
</pre>

<p>
<a target="_blank" href="LayerQuery.html">View Example </a> 
    | 
<a target="_blank" href="srcview/source/LayerQuery.mxml.html">
    Source Code </a> | <a target="_blank" href="LayerQuery3D.html"> View 
              in 3D </a> |
<a href="#Top">Back to top</a>
</p>
</div>
<div>
<h2><a name="Find"></a>Find</h2>
<p>Find is an operation supported by a map service to query features based on a 
    single String. It will search the attribute columns of the map layers inside the 
    map service and return matching features.</p>
<pre class="prettyprint">
      private function findData(q:String):void {
        var params:FindParameters=new FindParameters({
          returnGeometry: true, 
          searchText: q, 
          contains: !ex, 
          layerIds: service.getLayerIdsByName([&#39;Cities&#39;, &#39;Rivers&#39;, &#39;States&#39;]), 
          searchFields: [&quot;CITY_NAME&quot;, &quot;NAME&quot;, &quot;SYSTEM&quot;, &quot;STATE_ABBR&quot;, &quot;STATE_NAME&quot;]
          });
         service.find(params, processFindResults);
      }

      private function processFindResults(rs:FindResults):void {
        var fs:Array=rs.results;
        for (var i:int=0, c:int=fs.length; i &lt; c; i++) {
          processFindResult(fs[i]);
        }
        results.dataProvider=findValues;
      }
      private function processFindResult(res:FindResult):void {
        var title:String=res.layerName + &#39;:&#39; + res.foundFieldName + &#39; = &#39; + res.value;
        var ovs:Array= res.geometry;
        ...
      }
</pre>

<p>
<a target="_blank" href="Find.html">View Example </a> |
<a target="_blank" href="srcview/source/Find.mxml.html">
    Source Code </a> | 
<a href="#Top">Back to top</a>
</p>
</div>
<div>
<h2><a name="Geocode"></a>Geocode</h2>
<p>You can get the coordinates of a location by passing itss address or other 
    descriptions. You can use GeocodeService&#39;s 
<code>findAddressCandidates</code> method. You can dynamically construct an input 
    form based on the meta data of the GeocodeService such as &#39;addressFields&#39; 
    property. As mentioned earlier, you can use either call back or event handling 
    process.</p> 
 
<pre class="prettyprint">
    private function geocode(useCallback:Boolean):void {
        var inputs:*={};
        var fields:Array=svc.addressFields;
        for (var i:int=0; i &lt; fields.length; i++) {
          inputs[fields[i].name]=this[fields[i].name].text;
        }
        busy.visible=true;
        if (useCallback) {
          svc.findAddressCandidates(new GeocodeParameters({inputs: inputs}), processResults, handleError);
        } else {
          svc.addEventListener(ServiceEvent.GEOCODE_COMPLETE, function(evt:ServiceEvent):void {
              processResults(evt.data as GeocodeResults);
            });
          svc.addEventListener(ServiceEvent.ERROR, function(evt:ServiceEvent):void {
              handleError(evt.data as ServiceError);
            });
          svc.findAddressCandidates(new GeocodeParameters({inputs: inputs}));
        }
      }

      private function processResults(gcRes:GeocodeResults):void {
        busy.visible=false;
        results=[];
        if (gcRes.candidates) {
          for (var i:int=0, c:int=gcRes.candidates.length; i &lt; c; i++) {
           ...
        }
      }

      private function createMarker(gc:GeocodeResult):Marker {
        ...
      }
</pre>

<p>
<a target="_blank" href="Geocode.html">View Example </a> 
    | 
<a target="_blank" href="srcview/source/Geocode.mxml.html">
    Source Code </a> | <a target="_blank" href="Geocode3D.html">View in 3D </a> 
    |
<a href="#Top">Back to top</a>
</p>
</div>

  <div>
<h2><a name="ReverseGeocode"></a>Reverse Geocode</h2>
<p>You can also find the address of a given geographic coordinates (reverse 
    geocode), using 
<a href="../../../docs/com/google/maps/extras/arcgislink/GeocodeService.html">GeocodeService</a>&#39;s 
<code>reverseGeocode</code> method.</p> 
<pre class="prettyprint">
private function reverseGeocode(latlng:LatLng):void {
        if (latlng) {
          var params:ReverseGeocodeParameters=new ReverseGeocodeParameters({location: latlng, distance: 100});
          svc.reverseGeocode(params, function(result:ReverseGeocodeResult):void {
              if (result.address) {
                var html:String=&#39;&#39;;
                var attrs:*=result.address;
                for (var x:String in attrs) {
                  if (attrs.hasOwnProperty(x)) {
                    html+=x + &#39;: &#39; + attrs[x] + &#39;&lt;br/&gt;&#39;;
                  }
                }
                var loc:LatLng=result.location; 
                marker.setLatLng(loc);
                marker.openInfoWindow(new InfoWindowOptions({contentHTML: html}));
              } else {
                Alert.show(&#39;can not find address for point:&#39; + latlng.toString());
              }
            });
        }

      }
</pre>

<p>
<a target="_blank" href="ReverseGeocode.html">View 
    Example </a> |
<a target="_blank" href="srcview/source/ReverseGeocode.mxml.html">
    Source Code </a> | 
<a href="#Top">Back to top</a>
</p>
</div>
  <div>
<h2><a name="Multiple"></a>Use Mutiple Services</h2>
<p>A complete application generally uses more than one type of services together, 
    for Example, geocoding service results will be added to a map service. The 
    following Example combines GeocodeService.findAddressCandiate and 
    MapService.identify. </p> 
<pre class="prettyprint">
    private function doIdentify(latlng:LatLng):void {
       ...
        var idParams:IdentifyParameters=new IdentifyParameters({
          geometry: latlng, 
          layerOption: 'top', 
          tolerance: 5, 
          bounds: bnds, 
          width: size.x, 
          height: size.y, 
          dpi: 96, 
          returnGeometry: true});
        svc.identify(idParams, function processResults(res:IdentifyResults):void {
        ...
              map.openInfoWindow(latlng, new InfoWindowOptions({
              drawDefaultFrame: true, 
              customContent: idWin, 
              fillStyle: new FillStyle({alpha: 0.2})}));
            }
          });
      }
      
    private function doGeocode(addr:String):void {
      var params:GeocodeParameters=new GeocodeParameters({inputs: {Street: addr}});
      gc.findAddressCandidates(params, function(gcRes:GeocodeResults):void {
            Application.application.cursorManager.removeBusyCursor();
            if (gcRes.candidates && gcRes.candidates.length > 0) {
              var res:GeocodeResult=gcRes.candidates[0];
              ...
                doIdentify(res.location);
                return;
              }
            } 
      });
   }
</pre>

<p>
<a target="_blank" href="MultiService3D.html">View 
    Example in 3D </a> |
<a target="_blank" href="srcview/source/MultiService3D.mxml.html">
    Source Code </a> | 
<a href="#Top">Back to top</a>
</p>
</div>
  <div>
<h2><a name="3D"></a>3D/Perspective</h2>
<p>Google Flash API supports Perspective view since V1.13.The following are a few above samples running in 3D /Perspective mode:</p> 

      <ul>
          <li>Layer Query/Overlays: <a target="_blank" href="LayerQuery3D.html"> View 
              Example</a> |
              <a target="_blank" href="srcview/source/LayerQuery3D.mxml.html">
              Source Code</a></li>
                        <li>Map Click /Identify: <a target="_blank" href="MapClick3D.html"> View 
              Example</a> |
              <a target="_blank" href="srcview/source/MapClick3D.mxml.html">
              Source Code</a></li>
              <li>TileLayerOverlay: <a target="_blank" href="TileLayerOverlay3D.html"> View 
              Example</a> |
              <a target="_blank" href="srcview/source/TileLayerOverlay3D.mxml.html">
              Source Code</a></li>
               <li><b>Use Multiple Services(Map/Geocode):</b> <a target="_blank" href="MultiService3D.html"> View 
              Example</a> |
              <a target="_blank" href="srcview/source/MultiService3D.mxml.html">
              Source Code</a></li>
                        
              
      </ul>
</div>
    <h2><a name="credits"></a>Credits/Acknowledgements </h2>
    <p>This library embeded the following libraries/components, with all copyright 
        notices included in the modified <a target="_blank" href="../../../src/com/google/maps/extras/arcgislink/">source code</a>:</p>
    
<ul>
          <li>Adobe <a href="http://code.google.com/p/as3corelib/">AS3CoreLib</a>&#39;s JSON 
              package for JSON parsing, with modification to use OrderObject instead of 
              generic object.</li>
          <li>Manish Jethan&#39;s 
              <a href="http://manishjethani.com/guaranteeing-enumeration-order">Ordered Object
              </a>to work with Identify results with garanteed same order with server results 
              for AS3. 
          </li>
      </ul>    
<p>&nbsp;</p>
<p>&nbsp;</p>
<script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
    var pageTracker = _gat._getTracker("UA-3946449-10");
    pageTracker._trackPageview();
</script>
</body>
</html>
